package com.quick.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.quick.annotation.IgnoreToken;
import com.quick.serivce.IWxUserService;
import com.quick.wx.dto.WxUserLoginDTO;
import com.quick.wx.vo.WxUserLoginVo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@RestController
@RequestMapping("api/wx")
@Api(tags = "微信用户")
public class WxUserLoginController {
	
	@Autowired
	private IWxUserService wxUserService;
	
	@GetMapping("auth")
	@ApiOperation("微信授权")
	@IgnoreToken
	public Map<String,Object> auth(@RequestParam("code") String code) {
		return wxUserService.userAuth(code);
	}
	
	@PostMapping("wxLogin")
	@ApiOperation("微信登录")
	@IgnoreToken
	public String wxLogin(@RequestBody WxUserLoginDTO wxLogin) {
		String res = wxUserService.wxLogin(wxLogin);
		return res;
	}
	
	@GetMapping("getUser")
	@ApiOperation("获取用户")
	@IgnoreToken
	public WxUserLoginVo getUser() {
		return wxUserService.getUser();
	}
	@PostMapping("wxUpdateInfor")
	@ApiOperation("更新头像和昵称")
	@IgnoreToken
	public Boolean wxUpdateInfor(@RequestBody WxUserLoginDTO wxLogin) {
		return wxUserService.wxUpdateInfor(wxLogin);
	}
	
	

}
